home *** CD-ROM | disk | FTP | other *** search
- package javax.swing.text.rtf;
-
- import java.awt.Color;
- import java.util.Dictionary;
- import java.util.Enumeration;
- import java.util.Hashtable;
- import javax.swing.text.AttributeSet;
- import javax.swing.text.MutableAttributeSet;
- import javax.swing.text.SimpleAttributeSet;
- import javax.swing.text.Style;
- import javax.swing.text.StyleConstants;
- import javax.swing.text.TabStop;
-
- abstract class RTFReader$AttributeTrackingDestination implements RTFReader.Destination {
- // $FF: synthetic field
- private final RTFReader this$0;
- MutableAttributeSet characterAttributes;
- MutableAttributeSet paragraphAttributes;
- MutableAttributeSet sectionAttributes;
-
- public RTFReader$AttributeTrackingDestination(RTFReader var1) {
- this.this$0 = var1;
- this.characterAttributes = this.rootCharacterAttributes();
- var1.parserState.put("chr", this.characterAttributes);
- this.paragraphAttributes = this.rootParagraphAttributes();
- var1.parserState.put("pgf", this.paragraphAttributes);
- this.sectionAttributes = this.rootSectionAttributes();
- var1.parserState.put("sec", this.sectionAttributes);
- }
-
- public void begingroup() {
- MutableAttributeSet var1 = this.currentTextAttributes();
- MutableAttributeSet var2 = this.currentParagraphAttributes();
- AttributeSet var3 = this.currentSectionAttributes();
- this.characterAttributes = new SimpleAttributeSet();
- this.characterAttributes.addAttributes(var1);
- this.this$0.parserState.put("chr", this.characterAttributes);
- this.paragraphAttributes = new SimpleAttributeSet();
- this.paragraphAttributes.addAttributes(var2);
- this.this$0.parserState.put("pgf", this.paragraphAttributes);
- this.sectionAttributes = new SimpleAttributeSet();
- this.sectionAttributes.addAttributes(var3);
- this.this$0.parserState.put("sec", this.sectionAttributes);
- }
-
- public void close() {
- }
-
- MutableAttributeSet currentParagraphAttributes() {
- SimpleAttributeSet var1 = new SimpleAttributeSet(this.paragraphAttributes);
- TabStop[] var3 = (TabStop[])this.this$0.parserState.get("_tabs_immutable");
- if (var3 == null) {
- Dictionary var4 = (Dictionary)this.this$0.parserState.get("_tabs");
- if (var4 != null) {
- int var5 = (Integer)var4.get("stop count");
- var3 = new TabStop[var5];
-
- for(int var6 = 1; var6 <= var5; ++var6) {
- var3[var6 - 1] = (TabStop)var4.get(new Integer(var6));
- }
-
- this.this$0.parserState.put("_tabs_immutable", var3);
- }
- }
-
- if (var3 != null) {
- var1.addAttribute("tabs", var3);
- }
-
- Style var7 = (Style)this.this$0.parserState.get("paragraphStyle");
- if (var7 != null) {
- var1.setResolveParent(var7);
- }
-
- return var1;
- }
-
- public AttributeSet currentSectionAttributes() {
- SimpleAttributeSet var1 = new SimpleAttributeSet(this.sectionAttributes);
- Style var2 = (Style)this.this$0.parserState.get("sectionStyle");
- if (var2 != null) {
- var1.setResolveParent(var2);
- }
-
- return var1;
- }
-
- MutableAttributeSet currentTextAttributes() {
- SimpleAttributeSet var1 = new SimpleAttributeSet(this.characterAttributes);
- Integer var2 = (Integer)this.this$0.parserState.get("f");
- String var4;
- if (var2 != null) {
- var4 = (String)this.this$0.fontTable.get(var2);
- } else {
- var4 = null;
- }
-
- if (var4 != null) {
- StyleConstants.setFontFamily(var1, var4);
- } else {
- var1.removeAttribute(StyleConstants.FontFamily);
- }
-
- if (this.this$0.colorTable != null) {
- Integer var3 = (Integer)this.this$0.parserState.get("cf");
- if (var3 != null) {
- Color var5 = this.this$0.colorTable[var3];
- StyleConstants.setForeground(var1, var5);
- } else {
- var1.removeAttribute(StyleConstants.Foreground);
- }
- }
-
- if (this.this$0.colorTable != null) {
- Integer var6 = (Integer)this.this$0.parserState.get("cb");
- if (var6 != null) {
- Color var7 = this.this$0.colorTable[var6];
- var1.addAttribute(StyleConstants.Background, var7);
- } else {
- var1.removeAttribute(StyleConstants.Background);
- }
- }
-
- Style var8 = (Style)this.this$0.parserState.get("characterStyle");
- if (var8 != null) {
- var1.setResolveParent(var8);
- }
-
- return var1;
- }
-
- public void endgroup(Dictionary var1) {
- this.characterAttributes = (MutableAttributeSet)this.this$0.parserState.get("chr");
- this.paragraphAttributes = (MutableAttributeSet)this.this$0.parserState.get("pgf");
- this.sectionAttributes = (MutableAttributeSet)this.this$0.parserState.get("sec");
- }
-
- public void handleBinaryBlob(byte[] var1) {
- this.this$0.warning("Unexpected binary data in RTF file.");
- }
-
- public boolean handleKeyword(String var1) {
- if (var1.equals("ulnone")) {
- return this.handleKeyword("ul", 0);
- } else {
- Object var2 = RTFReader.access$0().get(var1);
- if (var2 != null) {
- RTFAttribute var3 = (RTFAttribute)var2;
- boolean var4;
- switch (var3.domain()) {
- case 0:
- var4 = var3.set(this.characterAttributes);
- break;
- case 1:
- var4 = var3.set(this.paragraphAttributes);
- break;
- case 2:
- var4 = var3.set(this.sectionAttributes);
- break;
- case 3:
- var4 = var3.set(this.this$0.documentAttributes);
- break;
- case 4:
- RTFReader.access$1(this.this$0).backing = this.this$0.parserState;
- var4 = var3.set(RTFReader.access$1(this.this$0));
- RTFReader.access$1(this.this$0).backing = null;
- break;
- default:
- var4 = false;
- }
-
- if (var4) {
- return true;
- }
- }
-
- if (var1.equals("plain")) {
- this.resetCharacterAttributes();
- return true;
- } else if (var1.equals("pard")) {
- this.resetParagraphAttributes();
- return true;
- } else if (var1.equals("sectd")) {
- this.resetSectionAttributes();
- return true;
- } else {
- return false;
- }
- }
- }
-
- public boolean handleKeyword(String var1, int var2) {
- boolean var3 = var2 != 0;
- if (var1.equals("fc")) {
- var1 = "cf";
- }
-
- if (var1.equals("f")) {
- this.this$0.parserState.put(var1, new Integer(var2));
- return true;
- } else if (var1.equals("cf")) {
- this.this$0.parserState.put(var1, new Integer(var2));
- return true;
- } else {
- Object var4 = RTFReader.access$0().get(var1);
- if (var4 != null) {
- RTFAttribute var5 = (RTFAttribute)var4;
- boolean var6;
- switch (var5.domain()) {
- case 0:
- var6 = var5.set(this.characterAttributes, var2);
- break;
- case 1:
- var6 = var5.set(this.paragraphAttributes, var2);
- break;
- case 2:
- var6 = var5.set(this.sectionAttributes, var2);
- break;
- case 3:
- var6 = var5.set(this.this$0.documentAttributes, var2);
- break;
- case 4:
- RTFReader.access$1(this.this$0).backing = this.this$0.parserState;
- var6 = var5.set(RTFReader.access$1(this.this$0), var2);
- RTFReader.access$1(this.this$0).backing = null;
- break;
- default:
- var6 = false;
- }
-
- if (var6) {
- return true;
- }
- }
-
- if (var1.equals("fs")) {
- StyleConstants.setFontSize(this.characterAttributes, var2 / 2);
- return true;
- } else if (var1.equals("sl")) {
- if (var2 == 1000) {
- this.characterAttributes.removeAttribute(StyleConstants.LineSpacing);
- } else {
- StyleConstants.setLineSpacing(this.characterAttributes, (float)var2 / 20.0F);
- }
-
- return true;
- } else if (!var1.equals("tx") && !var1.equals("tb")) {
- if (var1.equals("s") && this.this$0.paragraphStyles != null) {
- this.this$0.parserState.put("paragraphStyle", this.this$0.paragraphStyles[var2]);
- return true;
- } else if (var1.equals("cs") && this.this$0.characterStyles != null) {
- this.this$0.parserState.put("characterStyle", this.this$0.characterStyles[var2]);
- return true;
- } else if (var1.equals("ds") && this.this$0.sectionStyles != null) {
- this.this$0.parserState.put("sectionStyle", this.this$0.sectionStyles[var2]);
- return true;
- } else {
- return false;
- }
- } else {
- float var12 = (float)var2 / 20.0F;
- int var13 = 0;
- Number var8 = (Number)this.this$0.parserState.get("tab_alignment");
- if (var8 != null) {
- var13 = var8.intValue();
- }
-
- int var7 = 0;
- var8 = (Number)this.this$0.parserState.get("tab_leader");
- if (var8 != null) {
- var7 = var8.intValue();
- }
-
- if (var1.equals("tb")) {
- var13 = 5;
- }
-
- this.this$0.parserState.remove("tab_alignment");
- this.this$0.parserState.remove("tab_leader");
- TabStop var9 = new TabStop(var12, var13, var7);
- Object var10 = (Dictionary)this.this$0.parserState.get("_tabs");
- Integer var11;
- if (var10 == null) {
- var10 = new Hashtable();
- this.this$0.parserState.put("_tabs", var10);
- var11 = new Integer(1);
- } else {
- var11 = (Integer)((Dictionary)var10).get("stop count");
- var11 = new Integer(1 + var11);
- }
-
- ((Dictionary)var10).put(var11, var9);
- ((Dictionary)var10).put("stop count", var11);
- this.this$0.parserState.remove("_tabs_immutable");
- return true;
- }
- }
- }
-
- public abstract void handleText(String var1);
-
- protected void resetCharacterAttributes() {
- this.handleKeyword("f", 0);
- this.handleKeyword("cf", 0);
- this.handleKeyword("fs", 24);
- Enumeration var1 = RTFReader.access$0().elements();
-
- while(var1.hasMoreElements()) {
- RTFAttribute var2 = (RTFAttribute)var1.nextElement();
- if (var2.domain() == 0) {
- var2.setDefault(this.characterAttributes);
- }
- }
-
- this.handleKeyword("sl", 1000);
- this.this$0.parserState.remove("characterStyle");
- }
-
- protected void resetParagraphAttributes() {
- this.this$0.parserState.remove("_tabs");
- this.this$0.parserState.remove("_tabs_immutable");
- this.this$0.parserState.remove("paragraphStyle");
- StyleConstants.setAlignment(this.paragraphAttributes, 0);
- Enumeration var1 = RTFReader.access$0().elements();
-
- while(var1.hasMoreElements()) {
- RTFAttribute var2 = (RTFAttribute)var1.nextElement();
- if (var2.domain() == 1) {
- var2.setDefault(this.characterAttributes);
- }
- }
-
- }
-
- protected void resetSectionAttributes() {
- Enumeration var1 = RTFReader.access$0().elements();
-
- while(var1.hasMoreElements()) {
- RTFAttribute var2 = (RTFAttribute)var1.nextElement();
- if (var2.domain() == 2) {
- var2.setDefault(this.characterAttributes);
- }
- }
-
- this.this$0.parserState.remove("sectionStyle");
- }
-
- protected MutableAttributeSet rootCharacterAttributes() {
- SimpleAttributeSet var1 = new SimpleAttributeSet();
- StyleConstants.setItalic(var1, false);
- StyleConstants.setBold(var1, false);
- StyleConstants.setUnderline(var1, false);
- StyleConstants.setForeground(var1, this.this$0.defaultColor());
- return var1;
- }
-
- protected MutableAttributeSet rootParagraphAttributes() {
- SimpleAttributeSet var1 = new SimpleAttributeSet();
- StyleConstants.setLeftIndent(var1, 0.0F);
- StyleConstants.setRightIndent(var1, 0.0F);
- StyleConstants.setFirstLineIndent(var1, 0.0F);
- var1.setResolveParent(this.this$0.target.getStyle("default"));
- return var1;
- }
-
- protected MutableAttributeSet rootSectionAttributes() {
- SimpleAttributeSet var1 = new SimpleAttributeSet();
- return var1;
- }
- }
-